package com.digital.smartgrow.service.process.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.digital.smartgrow.dto.process.UpProcessPageDTO;
import com.digital.smartgrow.entity.process.UpProcess;
import com.digital.smartgrow.dao.process.UpProcessMapper;
import com.digital.smartgrow.service.process.UpProcessService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 审批流
 服务实现类
 * </p>
 *
 * @author sunyuechao
 * @since 2022-07-13
 */
@Service
public class UpProcessServiceImpl extends ServiceImpl<UpProcessMapper, UpProcess> implements UpProcessService {

    @Override
    public Object getListByPage(UpProcessPageDTO pageDTO) {
        Page<UpProcess> page = new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize());
        QueryWrapper<UpProcess> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(pageDTO.getStatus() != null, "status", pageDTO.getStatus());
        queryWrapper.like(StringUtils.isNotBlank(pageDTO.getName()), "name", pageDTO.getName());
        return this.page(page, queryWrapper);
    }

    @Override
    public Object getInfo(Integer id) {
        return this.getById(id);
    }
}
